package com.naiterui.ehp.bs.patient.repository;

import com.naiterui.common.repository.core.BaseJpaRepository;
import com.naiterui.ehp.bs.patient.domain.PatientFamily;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <pre>
 * 家庭成员持久化实现层
 * </pre>
 *
 * @author fangguanhong
 * @date 2020/4/10 下午5:25
 * @since 1.0.0
 */
@Repository
public interface IApPatientFamilyRepository extends BaseJpaRepository<PatientFamily, Long> {
    List<PatientFamily> findByPatientIdOrderByCreatedAtDescIdAsc(Long patientId);

    PatientFamily findFirstByPatientIdAndRelation(Long patientId, Integer selfCode);

    PatientFamily findFirstByNameAndRelation(String name, Integer relation);

    /**
     * 根据id和可见性查询
     * @param ids
     * @param visible
     * @return
     */
    List<PatientFamily> findByIdInAndVisible(List<Long> ids, Integer visible);

    /**
     * 根据患者id和身份证号查询
     * @param patientId
     * @param idCard
     * @return
     */
    PatientFamily findFirstByPatientIdAndIdCard(Long patientId, String idCard);
}
